import cv2, os, time
import numpy as np


class CamaroCap(object):

    def __init__(self):

        self.cap = cv2.VideoCapture(0)
        self.cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'))
        self.cap.set(cv2.CAP_PROP_FPS, 120)
        self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, 320)
        self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 240)

    def get_image_info(self, image):
        m = self.cap.get(cv2.CAP_PROP_FOURCC)
        f = self.cap.get(cv2.CAP_PROP_FPS)
        print(m)
        print(f)

    def Camaro_image(self):
        i = 0
        while (True):
            ret, frame = self.cap.read()
            if ret == False:
                break

            self.get_image_info(frame)

            cv2.imshow('ke', frame)  
            if cv2.waitKey(1) & 0xFF == ord('s'):
                cv2.imwrite('/home/pi/Desktop/ke/' + str(i) + '.jpg', frame)
                i += 1
            elif cv2.waitKey(1) & 0xFF == ord('q'):  #
                break


if __name__ == '__main__':
    outmasages = CamaroCap()

    outmasages.Camaro_image()

    outmasages.cap.release()
    cv2.destroyAllWindows()




